using Newtonsoft.Json;

namespace Mafool.Core.Test;

[TestClass]
public class NormalTest
{
    [TestMethod]
    public void TestMethod1()
    {
        var myObject = new Model
        {
            FloatField = 2.71828F,
            DoubleField = 3.1415926
        };
        var settings = new JsonSerializerSettings();

        string json = JsonConvert.SerializeObject(myObject, settings);
        Console.WriteLine($"Newtonsoft序 列 化：{json}");

        var obj = JsonConvert.DeserializeObject<Model>(json);
        Console.WriteLine($"Newtonsoft反序列化：{obj}");
        //Console.ReadLine();
    }


    [TestMethod]
    public void TestMethod2()
    {
        Assert.IsTrue("test.com".IsDomain());
        Assert.IsTrue("www.test.com".IsDomain());
        Assert.IsTrue("user.logic.test.com".IsDomain());

        Assert.IsFalse("abc".IsDomain());
        Assert.IsFalse("abc@com".IsDomain());

        //Assert.IsTrue(Reg.IsDomain("test.com"));
        //Assert.IsTrue(Reg.IsDomain("www.test.com") );
        //Assert.IsTrue(Reg.IsDomain("user.logic.test.com"));

        //Assert.IsFalse(Reg.IsDomain("abc"));
        //Assert.IsFalse(Reg.IsDomain("abc@com"));
    }


    [TestMethod]
    public void ExTest()
    {
        try
        {
            throw new Exception("测试异常");
        }
        catch (Exception ex)
        {
Console.WriteLine(ex.ErrorMessage());
        }
    }
}